package Tools
{
  import spark.components.TextArea;

  /**
   * ...
   * @author Roman Marchenko
   */
  public class Debug
  {
    private static var dbgout:TextArea;

    public static function log(... args):void
    {
      CONFIG::debug
      {
        trace(args);
        internalTrace(args);
      }
    }

    public static function setArea(area:TextArea):void
    {
      dbgout = area;
    }

    private static function internalTrace(... args):void
    {
      if (!dbgout)
      {
        return;
      }

      CONFIG::gui
      {
        for (var i:uint = 0; i < args.length; ++i)
        {
          dbgout.text += "\n";
          dbgout.text += args[i];
          dbgout.validateNow();
          dbgout.scroller.verticalScrollBar.value = dbgout.scroller.verticalScrollBar.maximum;
        }
      }
    }

  }
}